/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * StartupCompanyManager2012newGame.java
 *
 * Created on 27.11.2011, 16:26:03
 */
package startupcompanymanager2012;

import javax.swing.JOptionPane;

/**
 *
 * @author Matthäus
 */
public class StartupCompanyManager2012newGame extends javax.swing.JFrame {

    private String firstName, lastName;

    /** Creates new form StartupCompanyManager2012newGame */
    public StartupCompanyManager2012newGame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        newGamePanel = new javax.swing.JPanel();
        labelCompany = new javax.swing.JLabel();
        companyName = new javax.swing.JTextField();
        labelMainDev = new javax.swing.JLabel();
        labelMainDevFirst = new javax.swing.JLabel();
        mainDevFirst = new javax.swing.JTextField();
        labelMainDevLast = new javax.swing.JLabel();
        mainDevLast = new javax.swing.JTextField();
        cancelNewGame = new javax.swing.JButton();
        startNewGame = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(startupcompanymanager2012.StartupCompanyManager2012App.class).getContext().getResourceMap(StartupCompanyManager2012newGame.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N
        setResizable(false);

        newGamePanel.setBackground(resourceMap.getColor("newGamePanel.background")); // NOI18N
        newGamePanel.setName("newGamePanel"); // NOI18N
        newGamePanel.setPreferredSize(new java.awt.Dimension(250, 300));

        labelCompany.setFont(resourceMap.getFont("labelCompany.font")); // NOI18N
        labelCompany.setText(resourceMap.getString("labelCompany.text")); // NOI18N
        labelCompany.setName("labelCompany"); // NOI18N

        companyName.setText(resourceMap.getString("companyName.text")); // NOI18N
        companyName.setName("companyName"); // NOI18N

        labelMainDev.setFont(resourceMap.getFont("labelMainDev.font")); // NOI18N
        labelMainDev.setText(resourceMap.getString("labelMainDev.text")); // NOI18N
        labelMainDev.setName("labelMainDev"); // NOI18N

        labelMainDevFirst.setText(resourceMap.getString("labelMainDevFirst.text")); // NOI18N
        labelMainDevFirst.setName("labelMainDevFirst"); // NOI18N

        mainDevFirst.setText(resourceMap.getString("mainDevFirst.text")); // NOI18N
        mainDevFirst.setName("mainDevFirst"); // NOI18N

        labelMainDevLast.setText(resourceMap.getString("labelMainDevLast.text")); // NOI18N
        labelMainDevLast.setName("labelMainDevLast"); // NOI18N

        mainDevLast.setText(resourceMap.getString("mainDevLast.text")); // NOI18N
        mainDevLast.setName("mainDevLast"); // NOI18N

        cancelNewGame.setText(resourceMap.getString("cancelNewGame.text")); // NOI18N
        cancelNewGame.setName("cancelNewGame"); // NOI18N
        cancelNewGame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                disposeFrame(evt);
            }
        });

        startNewGame.setText(resourceMap.getString("startNewGame.text")); // NOI18N
        startNewGame.setName("startNewGame"); // NOI18N
        startNewGame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startNewGame(evt);
            }
        });

        javax.swing.GroupLayout newGamePanelLayout = new javax.swing.GroupLayout(newGamePanel);
        newGamePanel.setLayout(newGamePanelLayout);
        newGamePanelLayout.setHorizontalGroup(
            newGamePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(newGamePanelLayout.createSequentialGroup()
                .addGroup(newGamePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(newGamePanelLayout.createSequentialGroup()
                        .addGap(63, 63, 63)
                        .addComponent(labelCompany))
                    .addGroup(newGamePanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(newGamePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelMainDevFirst)
                            .addComponent(labelMainDevLast))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(newGamePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(mainDevFirst, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
                            .addComponent(mainDevLast)
                            .addComponent(labelMainDev)))
                    .addGroup(newGamePanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(companyName, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE))
                    .addGroup(newGamePanelLayout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addGroup(newGamePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(startNewGame, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                            .addComponent(cancelNewGame, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))))
                .addContainerGap())
        );
        newGamePanelLayout.setVerticalGroup(
            newGamePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(newGamePanelLayout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(labelCompany)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(companyName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(22, 22, 22)
                .addComponent(labelMainDev)
                .addGap(18, 18, 18)
                .addGroup(newGamePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mainDevFirst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelMainDevFirst))
                .addGap(12, 12, 12)
                .addGroup(newGamePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelMainDevLast)
                    .addComponent(mainDevLast, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(startNewGame, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(cancelNewGame)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(newGamePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(newGamePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

        private void startNewGame(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startNewGame
            if (companyName.getText().length() == 0 || mainDevFirst.getText().length() == 0 || mainDevLast.getText().length() == 0) {

                JOptionPane.showMessageDialog(null, "You have to complete all fields!");
            } else {
                Core.companyName = companyName.getText();
                Developer mainDev = new Developer(mainDevFirst.getText(), mainDevLast.getText());
                Core.devs.add(mainDev);
                Core.running = true;
                Pathfinder.pause = false;
                StartupCompanyManager2012View.mProjectsButton.setEnabled(true);
                StartupCompanyManager2012View.mStaffButton.setEnabled(true);
                StartupCompanyManager2012View.cInfoButton.setEnabled(true);
                StartupCompanyManager2012View.mCompanyButton.setEnabled(false);
                StartupCompanyManager2012View.labelCompanyName.setText(Core.companyName);
                StartupCompanyManager2012View.liveBudget.setText(Core.nfmt.format(Core.capital));
                Core.startCalendar();
                StartupCompanyManager2012View.livelDate.setText(Core.calendar.toString());
                dispose();
                addGenres();
                addTypes();
                addFocuses();
                addPlatforms();
                addLanguages();
            }
    }//GEN-LAST:event_startNewGame

    private void disposeFrame(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_disposeFrame
        dispose();
    }//GEN-LAST:event_disposeFrame
    private void addGenres() {

        Game.genres.add(new Genre("Puzzle", 250.00, 5000));
        Game.genres.add(new Genre("Arcade", 500.00, 7000));
        Game.genres.add(new Genre("Adventure", 750.00, 11500));
        Game.genres.add(new Genre("Simulation", 1000.00, 15000));
        Game.genres.add(new Genre("Table", 350.00, 6000));

    }

    private void addTypes() {

        Game.types.add(new Type("Sci-Fi", 500.00, 5000));
        Game.types.add(new Type("Historical", 300.00, 3000));
        Game.types.add(new Type("Social", 400.00, 4000));
        Game.types.add(new Type("Animal", 200.00, 2000));
        Game.types.add(new Type("Sports", 500.00, 5000));

    }

    private void addFocuses() {

        Game.focuses.add(new Focus("Normal", 1.00, 1.00, 1.00));
        Game.focuses.add(new Focus("Saving", 0.75, 1.00, 1.25));
        Game.focuses.add(new Focus("Speed", 1.10, 0.85, 1.30));
        Game.focuses.add(new Focus("Quality", 1.35, 1.20, 0.75));

    }

    private void addPlatforms() {

        Game.platforms.add(new Platform("PC", 1.00, 1.00, 1.00));
        Game.platforms.add(new Platform("Mac", 1.00, 1.00, 1.00));
        Game.platforms.add(new Platform("Universal", 1.00, 1.00, 1.00));
        Game.platforms.add(new Platform("Unix", 1.00, 1.00, 1.00));
        Game.platforms.add(new Platform("Sony", 1.00, 1.00, 1.00));
        Game.platforms.add(new Platform("Android", 1.00, 1.00, 1.00));
        Game.platforms.add(new Platform("Xbox360", 1.00, 1.00, 1.00));
        Game.platforms.add(new Platform("iOS", 1.00, 1.00, 1.00));
        Game.platforms.add(new Platform("Nintendo", 1.00, 1.00, 1.00));

    }

    private void addLanguages() {

        Game.languages.add(new Language("C", 1.00, 1.00, 1.00));
        Game.languages.add(new Language("C++", 1.00, 1.00, 1.00));
        Game.languages.add(new Language("Flash", 1.00, 1.00, 1.00));
        Game.languages.add(new Language("Java", 1.00, 1.00, 1.00));
        Game.languages.add(new Language("PHP", 1.00, 1.00, 1.00));
        Game.languages.add(new Language("Perl", 1.00, 1.00, 1.00));
        Game.languages.add(new Language("Python", 1.00, 1.00, 1.00));
        Game.languages.add(new Language("Ruby", 1.00, 1.00, 1.00));
        Game.languages.add(new Language("Visual Basic", 1.00, 1.00, 1.00));

    }

    /**
     * @param args the command line arguments
     */
    public static void init(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(StartupCompanyManager2012newGame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(StartupCompanyManager2012newGame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(StartupCompanyManager2012newGame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(StartupCompanyManager2012newGame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new StartupCompanyManager2012newGame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelNewGame;
    private javax.swing.JTextField companyName;
    private javax.swing.JLabel labelCompany;
    private javax.swing.JLabel labelMainDev;
    private javax.swing.JLabel labelMainDevFirst;
    private javax.swing.JLabel labelMainDevLast;
    private javax.swing.JTextField mainDevFirst;
    private javax.swing.JTextField mainDevLast;
    private javax.swing.JPanel newGamePanel;
    private javax.swing.JButton startNewGame;
    // End of variables declaration//GEN-END:variables
}
